import { Field, ObjectType } from '@nestjs/graphql';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { CommonSchema } from 'src/common/mongodb/commonSchema';

@ObjectType({ description: '后台菜单数据' })
@Schema({ collection: 'MenuData' })
export class Menu extends CommonSchema {
  @Field(() => String)
  @Prop()
  name: string;

  @Field(() => String)
  @Prop()
  title: string;

  @Field(() => String, { nullable: true })
  @Prop({ required: false })
  icon: string;

  @Field(() => String, { nullable: true })
  @Prop({ required: false })
  badge: string;

  @Field(() => String, { nullable: false })
  @Prop({ required: false })
  target: string;

  @Field(() => String)
  @Prop()
  path: string;

  @Field(() => String, { nullable: true })
  @Prop()
  link: string;

  @Field(() => String)
  @Prop()
  component: string;

  @Field(() => Boolean)
  @Prop()
  renderMenu: boolean;

  @Field(() => String, { nullable: true })
  @Prop({ required: false })
  parent?: string;

  @Field(() => [String], { nullable: true })
  @Prop({ required: false })
  permission?: string[];

  @Field(() => Boolean)
  @Prop()
  cacheable: boolean;
}
export type MenuDocument = Menu & Document;
export const MenuSchema = SchemaFactory.createForClass(Menu);
